package com.omybug.study.config;

import com.omybug.study.entity.BenzCar;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author: omybug
 * @date: 18/9/18 14:21
 */
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        boolean isContaion = registry.containsBeanDefinition("com.omybug.study.entity.MazdaCar");
        System.out.println("is contaion " + isContaion);
        RootBeanDefinition beanDefinition = new RootBeanDefinition(BenzCar.class);
//        beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);

        registry.registerBeanDefinition("benz", beanDefinition);
    }

}
